package <packageRoot>;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Connection {
	
	private static Connection instance;
	
	private EntityManager entityManager;
	
	private Connection() {
		createEntityManager();
	}

	public static Connection getInstance() {		
		if (instance == null) {
			instance = new Connection();
		}		
		return instance;
	}

	private void createEntityManager() {
		
		try {			
			EntityManagerFactory emf = Persistence.createEntityManagerFactory("<persistenceUnitName>");			
			entityManager = emf.createEntityManager();			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}
}
